package com.grgbanking.it.common.entity;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

/**
 * 页面查询传递的参数
 * 
 * PageQuery
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2014-11-6 上午9:18:32
 * 
 * @version 1.0.0
 * 
 */
public class PageQuery {
	private Integer start;
	private Integer limit;
	private String sort;

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public Integer getLimit() {
		return limit;
	}

	public void setLimit(Integer limit) {
		this.limit = limit;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getSort() {
		return sort;
	}

	public Map<String, String> getOrder() {
		Map<String, String> map = new HashMap<String, String>();
		if (this.sort == null || "".equals(this.sort)) {
			map.put("direction", "DESC");
			map.put("property", "id");
		} else {
			JSONArray jsArray = JSONArray.fromObject(this.sort);
			JSONObject obj = (JSONObject) jsArray.get(0);
			map.put("direction", obj.getString("direction"));
			map.put("property", obj.getString("property"));
		}
		return map;
	}

}
